import java.util.Iterator;
import java.util.Map;
import java.util.HashMap;

public class FileList implements ShellList, Iterable<Map.Entry<String, ShellFile>> {
	
	private Map<String, ShellFile> fileMap;
	int size;
	
	public FileList() {
		fileMap = new HashMap<String, ShellFile>();
		size = 0;
	}
	
	public void addFile(ShellFile addMe) {
		fileMap.put(addMe.getName(), addMe);
		size++;
	}
	
	public void removeFile(String fileName) {
		fileMap.remove(fileName);
		size--;
	}
	
	public boolean hasFile(String fileName) {
		return fileMap.containsKey(fileName);
	}
	
	public ShellFile getFile(String fileName){
		return fileMap.get(fileName);
	}

    public Iterator<String> iterator() {
		return fileMap.entrySet().iterator();
	}
	
	public boolean isEmpty() {
		return (size == 0);
	}
	
	public int length() {
		return size;
	}

	public static void main(String[] args) {
		ShellList fl = new FileList();
		fl.addFile(new ShellFile("File1"));
		ShellFile file1 = fl.getFile("File1");
		System.out.println(file1.getName());
	}

}